﻿Public Class Project
    Dim com As New Common
    Dim fs As New FS
    Public project_name As String
    Public creating As Boolean = False
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.AddExtension = True
        OpenFileDialog1.FileName = ""
        OpenFileDialog1.Title = "DevBox - Open a project solution"
        OpenFileDialog1.DefaultExt = ".dbox"
        OpenFileDialog1.Filter = "DevBox solution (*.dbox)|*.dbox|DevBox code (*.dbxc)|*.dbxc|DevBox form (*.dbxf)|*.dbxf"
        OpenFileDialog1.ShowDialog()

    End Sub

    Private Sub Project_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Startup.Close()

    End Sub

    Private Sub Project_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        NewProject.Show()
        creating = True
        While creating = True
            Application.DoEvents()
        End While

  
        Dim projectname As String = project_name
        Trace.WriteLine("Creating project: " + projectname)
        If (System.IO.Directory.Exists(fs.Startup + "Projects")) Then
        Else
            System.IO.Directory.CreateDirectory(fs.Startup + "Projects")
        End If
        System.IO.Directory.CreateDirectory(fs.Startup + "Projects\" + projectname)
        System.IO.File.Copy(fs.Startup + "Templates\form.designer.vb", fs.Startup + "Projects\" + projectname + "\form.designer.vb")
        System.IO.File.WriteAllText(fs.Startup + "Projects\" + projectname + "\" + projectname + ".dbox", "")
        Main2.Show()
        Me.Hide()

    End Sub
End Class